import { useState } from "react"
import { useRootStore } from "../../stores/TodoStore/RootStore"
function TodoHeader({createTitle}) {
  const [title,setTitle] = useState("")
  const { todoListStore } = useRootStore()
  return (
    <div>
        <input onChange={event=>{setTitle(event.target.value)}} onKeyUp={event=>
          {if(event.key==="Enter") {
            todoListStore.createTitle(title)
            setTitle("")
          }}
        }
          value={title}/>
    </div>
  )
}

export default TodoHeader